package situ.autoweter.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import situ.autoweter.entity.SyEmp;
import situ.autoweter.service.RdChangemaxvalueService;
import situ.autoweter.entity.RdChangemaxvalue;
import situ.autoweter.service.SyEmpService;

import java.util.*;
/**
 * RdChangemaxvalue的路由接口服务
 * 
 * @author 胡文
 *
 */
@Controller
public class RdChangemaxvalueController {

	/** RdChangemaxvalueService服务 */
	@Autowired
	private RdChangemaxvalueService rdChangemaxvalueService;

	@Autowired
	private SyEmpService syEmpService;
	/**
	 * 查询所有RdChangemaxvalue数据的方法
	 * @param value
	 * @return
	 */
	@RequestMapping(value = "queryRdChangemaxvalue", produces = {"application/json;charset=UTF-8"})
	public String find(RdChangemaxvalue value,Map map) {
		 List<RdChangemaxvalue> list= rdChangemaxvalueService.find(value);
         map.put("items",list);
         return "页面名称自己改";
	}
	
	/**
	 * 通过id查询RdChangemaxvalue数据的方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "queryRdChangemaxvalueById/{id}", produces = {"application/json;charset=UTF-8"})
	public String findOne(@PathVariable(name="id") Object id,Map map) {
        RdChangemaxvalue obj=  rdChangemaxvalueService.findOne(id);
        map.put("RdChangemaxvalue",obj);
        return "页面名称自己改";
	}
	
	/**
	 * 插入RdChangemaxvalue属性不为空的数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "saveRdChangemaxvalue", produces = {"application/json;charset=UTF-8"})
	public String save(RdChangemaxvalue value) {
		  rdChangemaxvalueService.saveNotNull(value);
        return "redirect:/queryRdChangemaxvalue";
	}
	
	/**
	 * 更新RdChangemaxvalue属性不为空的数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "updateRdChangemaxvalue", produces = {"application/json;charset=UTF-8"})
	public String update(RdChangemaxvalue value) {
		  rdChangemaxvalueService.updateNotNullById(value);
          return "redirect:/queryRdChangemaxvalue";
	}
	
	/**
	 * 通过id删除RdChangemaxvalue数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "delRdChangemaxvalueById/{id}", produces = {"application/json;charset=UTF-8"})
	public String delete(@PathVariable(name="id") Object id) {
		  rdChangemaxvalueService.deleteById(id);
          return "redirect:/queryRdChangemaxvalue";
	}

	/*
	 * rd_reportMaxValue.html界面功能
	 *
	 * */
	@RequestMapping("rd_reportMaxValue.html")
	public String queryByIf(RdChangemaxvalue value,Map map,
							@RequestParam(value = "d1",required = false) String d1,
							@RequestParam(value="d2",required = false) String d2,
							@RequestParam(defaultValue ="1",required = false) int startPage,
							@RequestParam(defaultValue = "5",required = false) int PageSize
	){
		if(d1!=null&&d1!=""&&d2!=null&&d2!=""){
			System.out.println(java.time.Instant.ofEpochSecond(new Long(d1)));
			System.out.println(java.time.Instant.ofEpochSecond(new Long(d2)));
			value.setDatee(java.time.Instant.ofEpochSecond(new Long(d1)));
			value.setDatee2(java.time.Instant.ofEpochSecond(new Long(d2)));


		}

		PageHelper.startPage(startPage, PageSize);

		//多条件查询
		List<Map> list=rdChangemaxvalueService.queryByIf(value);

		//所有的操作人员
		List<SyEmp> syEmplist= syEmpService.find(null);

		PageInfo pageInfo = new PageInfo<Map>(list,5);
		map.put("pageInfo", pageInfo);
		map.put("startPage", startPage);
		map.put("PageSize", PageSize);

		map.put("syEmplist", syEmplist);
		map.put("list", list);
		return "page/rd_reportMaxValue.html";
	}
}
